home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / Dave Mark / Mac C Primer 1 (SC++7) / 3.1 - Hello2 / Hello2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-27  |  1.3 KB  |  72 lines  |  [TEXT/KAHL]

  1. /********************************************************/
  2. /*                                                        */
  3. /*  Hello2 Code from Chapter Three of                    */
  4. /*                                                        */
  5. /*    *** The Macintosh Programming Primer, 2nd Ed. ***    */
  6. /*                                                      */
  7. /*    Copyright 1992, Dave Mark and Cartwright Reed       */
  8. /*                                                        */
  9. /********************************************************/
  10.  
  11. #define kBaseResID             128
  12. #define    kMoveToFront        (WindowPtr)-1L
  13.  
  14. #define    kHorizontalPixel    30
  15. #define    kVerticalPixel        50
  16.  
  17.  
  18. /***************/
  19. /*  Functions  */
  20. /***************/
  21.  
  22. void    ToolBoxInit( void );
  23. void    WindowInit( void );
  24.  
  25.  
  26. /****************** main ***************************/
  27.  
  28. void    main( void )
  29. {
  30.      ToolBoxInit();
  31.      WindowInit();
  32.      
  33.     while ( !Button() ) ;
  34. }
  35.  
  36.  
  37. /****************** ToolBoxInit *********************/
  38.  
  39. void    ToolBoxInit( void )
  40. {
  41.     InitGraf( &qd.thePort );
  42.     InitFonts();
  43.     InitWindows();
  44.     InitMenus();
  45.     TEInit();
  46.     InitDialogs( 0L );
  47.     InitCursor();
  48. }
  49.  
  50.  
  51. /****************** WindowInit ***********************/
  52.                                 
  53. void    WindowInit( void )
  54. {
  55.     WindowPtr     window;
  56.  
  57.     window = GetNewWindow( kBaseResID , nil,
  58.                                     kMoveToFront );
  59.     
  60.     if ( window == nil )
  61.     {
  62.         SysBeep( 10 );    /*  Couldn't load the WIND resource!!!  */
  63.         ExitToShell();
  64.     }
  65.     
  66.     ShowWindow( window );
  67.     SetPort( window );
  68.     
  69.     MoveTo( kHorizontalPixel, kVerticalPixel );
  70.     DrawString("\pHello, world!");
  71. }
  72.